<?php

declare(strict_types=1);

namespace App\Entity;

use App\Models\OrderOperationLog;

class OrderOperationLogEntity extends ABaseEntity
{
    public function __construct(OrderOperationLog $model)
    {
        $this->model = $model;
    }

    /**
     * @return OrderOperationLogEntity[]
     */
    public static function getLogsByOrderId(int $orderId)
    {
        $collection = OrderOperationLog::where('order_id', $orderId)->get();
        if ($collection->isEmpty()) {
            return [];
        }

        $ret = [];
        foreach ($collection as $model) {
            $ret[] = new self($model);
        }

        return $ret;
    }

    /**
     * @return int
     */
    public function getId()
    {
        return (int) $this->model->id;
    }

    public function getOrderId(): int
    {
        return (int) $this->model->order_id;
    }

    public function setOrderId(int $order_id): void
    {
        $this->model->order_id = $order_id;
    }

    public function getOperatorId(): int
    {
        return $this->model->operator_id;
    }

    public function setOperatorId(int $operator_id): void
    {
        $this->model->operator_id = $operator_id;
    }

    public function getOperatorName(): string
    {
        return $this->model->operator_name;
    }

    public function setOperatorName(string $operator_name): void
    {
        $this->model->operator_name = $operator_name;
    }

    public function getContent(): string
    {
        return $this->model->content;
    }

    public function setContent(string $content): void
    {
        $this->model->content = $content;
    }

    public function getType(): int
    {
        return $this->model->type;
    }

    public function setType(int $type): void
    {
        $this->model->type = $type;
    }

    /**
     * 订单创建时间
     *
     * @return string
     */
    public function getCreatedAt()
    {
        return $this->model->created_at;
    }
}
